package com.hex.liyue.usermodule.presenter;

import com.hex.liyue.commonmodule.manager.UserManager;
import com.hex.liyue.commonmodule.utils.AppStackUtil;
import com.hyphenate.EMCallBack;
import com.hyphenate.chat.EMClient;

/**
 * 这是一个设置界面的逻辑类
 * Created by yukoyuan on 16/6/17.
 */
public class SettingPresenter {
    ISetingView iSetingView;

    public SettingPresenter(ISetingView iSetingView) {
        this.iSetingView = iSetingView;
    }

    /**
     * 这是一个退出登录的方法
     */
    public void exitLogin() {
        //此方法为异步方法,退出环信登录
        EMClient.getInstance().logout(false, new EMCallBack() {
            @Override
            public void onSuccess() {
                UserManager.clearAllInfo();
                AppStackUtil.getInstance().finishAllActivity();
                iSetingView.startLoginAndRegistActivity();
            }

            @Override
            public void onProgress(int progress, String status) {

            }

            @Override
            public void onError(int code, String message) {
                iSetingView.showT("退出登录失败");
            }
        });


    }
}
